package com.xlcszsgc.module.resource.vo;

import java.util.HashMap;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;



import com.xlcszsgc.core.configure.PropertiesVo;

/**
 * @Title: CategoryVo.java
 * @Package com.xlcszsgc.module.category.vo
 * @Description: 分类值装载
 * @author Zhaoqt  
 * @date 2014-5-23 上午1:18:20
 * @version V1.0
 */
@Service(value = "com.xlcszsgc.module.resource.vo.CategoryVo")
public class CategoryVo {

	private Map<String, String> category = null;
	@Autowired
	@Qualifier(value = "propertiesVo")
	private PropertiesVo propertiesVo; 
	
	public Map<String, String> getCategory() {
		if(category != null && category.size() > 0) {
			
		} else {
			initMap();
		}
		return category;
	}
	
	private void initMap() {
		category = new HashMap<String, String>();
		String code =  propertiesVo.getViewCategoryCode();
		String name = propertiesVo.getViewCategoryName();
		String codeArry[] = code.split(",");
		String nameArry[] = name.split(",");
		int codeLength =  codeArry.length;
		int nameLength = nameArry.length;
		if(codeLength <= nameLength) {
			for(int i = 0; i < codeLength; i ++) {
				category.put(codeArry[i], nameArry[i]);
			}
		} else {
			for(int i = 0; i < nameLength; i ++) {
				category.put(codeArry[i], nameArry[i]);
			}
		}
		
	}

}
